﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Common/Master.master" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentForm" runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHtml" runat="Server">
    <div class="easyui-layout" data-options="fit:true,border:false">
        <div data-options="region:'west',split:false,fit:true,border:false">
            <ul class="easyui-tree" id="tree" data-options="border:false"></ul>
        </div>
        <div data-options="region:'south'" style="height: 35px; border-bottom: 0px; border-left: 0px; border-right: 0px;" class="edit_bottom">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-save'" id="buttonOk">确 定</a>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            $.InvokeAjax({
                url: "Api/V1/System/GetTree",
                data: {},
                callBack: function (data) {
                    var pguid = ""; var checkid = "";
                    var obj = $.StrToJson(data).Results.Results;
                    $.fn.Tree.Init({ id: 'tree', data: obj, checkbox: true, cascadeCheck: true });
                }
            });


            $.InvokeAjax({
                url: "Api/V1/System/GetListJurisdictionMenu",
                data: { id: $.getUrlParamer("JurisdictionID") },
                callBack: function (data) {
                    var obj = $.StrToJson(data).Results;
                    $.each(obj, function (i, item) {
                        var node = $('#tree').tree('find', item.ID);
                        if (node != null && item.Leaf == true) {
                            $('#tree').tree('check', node.target);
                        }
                    });
                }
            });


            $("#buttonOk").click(function () {
                var nodes = $('#tree').tree('getChecked', ['checked', 'indeterminate']);

                var MenuList = [];
                $.each(nodes, function (i, node) {
                    MenuList.push({ id: node.id });
                })
                $.InvokeAjax({
                    url: "Api/V1/System/AddJurisdictionMenu",
                    data: { MenuList: MenuList, id: $.getUrlParamer("JurisdictionID") },
                    callBack: function (data) {
                        alert('设置成功！');
                        $.DialogClose(false);
                    }
                });
            });


        });
    </script>
</asp:Content>
<%--未调整--%>
